/*
 * Copyright 2002-2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.beans.factory.config;

import org.springframework.beans.BeansException;

/**
 * Allows for custom modification of an application context's bean definitions,
 * adapting the bean property values of the context's underlying bean factory.
 *
 * <p>Application contexts can auto-detect BeanFactoryPostProcessor beans in
 * their bean definitions and apply them before any other beans get created.
 *
 * <p>Useful for custom config files targeted at system administrators that
 * override bean properties configured in the application context.
 *
 * <p>See PropertyResourceConfigurer and its concrete implementations
 * for out-of-the-box solutions that address such configuration needs.
 *
 * <p>A BeanFactoryPostProcessor may interact with and modify bean
 * definitions, but never bean instances. Doing so may cause premature bean
 * instantiation, violating the container and causing unintended side-effects.
 * If bean instance interaction is required, consider implementing
 * {@link BeanPostProcessor} instead.
 *
 * @author Juergen Hoeller
 * @see BeanPostProcessor
 * @see PropertyResourceConfigurer
 * @since 06.07.2003
 */

/**
 * 允许自定义修改应用程序上下文的 bean 定义，调整上下文底层 bean 工厂的 bean 属性值。
 * <p>应用程序上下文可以在它们的 bean 定义中自动检测 BeanFactoryPostProcessor bean，并在创建任何其他 bean 之前应用它们。
 * <p>对于面向系统管理员的自定义配置文件很有用，这些文件覆盖在应用程序上下文中配置的 bean 属性。
 * <p>请参阅 PropertyResourceConfigurer 及其具体实现，以了解满足此类配置需求的开箱即用解决方案。
 * <p> BeanFactoryPostProcessor 可以与 bean 定义交互和修改，但绝不能与 bean 实例交互。
 * 这样做可能会导致 bean 过早实例化、违反容器并导致意外的副作用。
 * 如果需要 bean 实例交互，请考虑实现 {@link BeanPostProcessor}。
 * <p>
 * todo  这个是通过 BeanDefinition 读取到的bean定义信息,在将bean的定义信息放入  BeanFactory 之前对 BeanFactory 多做的增强工作,
 * todo  例如创建数据库连接池的增强工作 具体实现类详见 {@link PlaceholderConfigurerSupport} 或者实现类 {@link org.springframework.context.annotation.ConfigurationClassPostProcessor}
 * </p>
 *
 * @Author yangSen
 * @date 2021-12-24 15:14
 * @see BeanPostProcessor
 * @see PropertyResourceConfigurer
 */
@FunctionalInterface
public interface BeanFactoryPostProcessor {

	/**
	 * Modify the application context's internal bean factory after its standard
	 * initialization. All bean definitions will have been loaded, but no beans
	 * will have been instantiated yet. This allows for overriding or adding
	 * properties even to eager-initializing beans.
	 * <p>
	 * 在标准初始化之后修改应用程序上下文的内部 bean 工厂。所有 bean 定义都将被加载，
	 * 但尚未实例化任何 bean。这甚至允许覆盖或添加属性，甚至是急切初始化的 bean。
	 * </p>
	 *
	 * @param beanFactory the bean factory used by the application context
	 * @throws org.springframework.beans.BeansException in case of errors
	 */
	void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException;

}
